//
//  YLRegularFinancingViewController.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/13.
//  Copyright © 2017年 she1323. All rights reserved.
//  定期理财

#import "YLRegularFinancingViewController.h"
#import <Masonry.h>
#import "YLRegularFinancingTopView.h"
#import "YLGlobeHeader.h"
#import "XXPageTabView.h"
#import "XXPageTabItemLable.h"
#import "YLRegularFinancingListViewController.h"
#import "YLContinuationRecordController.h"
@interface YLRegularFinancingViewController ()<XXPageTabViewDelegate>
@property (nonatomic, strong) XXPageTabView *pageTabView;
@property (nonatomic, weak) YLRegularFinancingTopView *topView;
@end

@implementation YLRegularFinancingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"普惠";
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    YLRegularFinancingTopView *topView = [[YLRegularFinancingTopView alloc] initWithFrame:CGRectMake(0, 0, YLScreenW, YLScreenW * 322 / 750.0)];
    _topView = topView;
    [self.view addSubview:topView];
    
    self.view.backgroundColor = YLBackGroundColor;
    [self setUpPageTabView];
    
    UIButton *recordButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [recordButton setTitle:@"续投记录" forState:UIControlStateNormal];
    recordButton.titleLabel.font = [UIFont systemFontOfSize:13.0f];
    recordButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [recordButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [recordButton addTarget:self action:@selector(continuationRecord) forControlEvents:UIControlEventTouchUpInside];
    recordButton.bounds = CGRectMake(0, 0, 70, 30);
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:recordButton];
    
}

- (void)continuationRecord
{
    YLContinuationRecordController *record = [[YLContinuationRecordController alloc] init];
    [self.navigationController pushViewController:record animated:YES];
}

- (void)setUpPageTabView
{
    
    
    YLRegularFinancingListViewController *vc1 = [[YLRegularFinancingListViewController alloc] init];
    vc1.canJump = NO;
    vc1.type = 0;
    vc1.verifying = YES;
    
    YLRegularFinancingListViewController *vc2 = [[YLRegularFinancingListViewController alloc] init];
    vc2.canJump = YES;
    vc2.type = 1;
    vc2.verifying = NO;
    
    
    YLRegularFinancingListViewController *vc3 = [[YLRegularFinancingListViewController alloc] init];
    vc3.canJump = YES;
    vc3.type = 0;
    vc3.verifying = NO;
    
    [self addChildViewController:vc1];
    [self addChildViewController:vc2];
    
    [self addChildViewController:vc3];
    
    //支持网易云音乐，今日头条，微博等切换栏效果
    self.pageTabView = [[XXPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"审核中",@"持有中",@"已到期"]];
    self.pageTabView.frame = CGRectMake(0, CGRectGetMaxY(_topView.frame) + 10, self.view.frame.size.width , self.view.frame.size.height - CGRectGetMaxY(_topView.frame) - 44 - 20);
    self.pageTabView.tabSize = CGSizeMake(YLScreenW, 44.0f);
    self.pageTabView.selectedColor = YLLOrgColor;
    self.pageTabView.separatorColor = YLColor(200, 200, 200);
    self.pageTabView.unSelectedColor = YLLineColor;
    self.pageTabView.delegate = self;
    self.pageTabView.indicatorHeight = 1.5;
    self.pageTabView.titleStyle = XXPageTabTitleStyleDefault;
    self.pageTabView.indicatorStyle = XXPageTabIndicatorStyleStretch;
    self.pageTabView.indicatorWidth = YLScreenW / 3.0 - 30;
    [self.view addSubview:self.pageTabView];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pageTabViewDidEndChange {
}


@end
